const { EventEmitter } = require('events')

const evt = new EventEmitter();

evt.on('hello', () => console.log('hello event happen!'))
evt.on('bye', () => {
  console.log('good bye')
  // 退出当前进程
  process.exit()
})

setInterval(() => {
  evt.emit('hello')
}, 1000)
setTimeout(() => {
  evt.emit('bye')
}, 5000)
